package com.alias.app_interface;


import com.alias.model.Employees;

import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableModel;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Пользователь
 * Date: 06.03.13
 * Time: 1:17
 * To change this template use File | Settings | File Templates.
 */
public class MyTableModel extends AbstractTableModel {
    private List<Employees> employeesList;
    private String[] columnNames;
    private int rowIndex;
    private int columnIndex;

    public MyTableModel(List<Employees> list, String[] strings) {
        super();
        this.employeesList = list;
        this.columnNames = strings;
        this.rowIndex = 0;
        this.columnIndex = 0;
    }
    @Override
    public int getRowCount() {
        return employeesList.size();  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public int getColumnCount() {
        return columnNames.length;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    public void addRow(Employees employee) {
        setValueAt(employee.getCode(), rowIndex, columnIndex++);
        setValueAt(employee.getName(), rowIndex, columnIndex++);
        setValueAt(employee.getSurname(), rowIndex, columnIndex++);
        setValueAt(employee.getBirthday(), rowIndex, columnIndex++);
        setValueAt(employee.getCountry(), rowIndex, columnIndex++);
        setValueAt(employee.getCity(), rowIndex, columnIndex++);
        setValueAt(employee.getSalaryAmount(), rowIndex, columnIndex++);
        rowIndex++;
    }
}


